/// USE "ANES2020_replicationdata.dta"



//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MANUSCRIPT Table 2 (bottom two rows) /////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Cross-tab of rural residency ("ruralres") and binary rural identity ("rasocid_binary")
tab ruralres rasocid_binary
//////////////////////////////////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MANUSCRIPT Figure 3 //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// rural feeling thermometer score ("ftrural") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanft= ftrural (sd) sdft=ftrural (count) n=ftrural, by(ruralres rasocid_binary)
generate hift = meanft + invttail(n-1,0.025)*(sdft / sqrt(n))
generate lowft = meanft - invttail(n-1,0.025)*(sdft / sqrt(n))
graph bar meanft, over(ruralres) over(rasocid_binary)
graph bar meanft, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanft rasocid_binary, color(gray))(rcap hift lowft rasocid_binary, color(gray)), by(ruralres) scheme(s1mono)

/// Rural resentment ("rc") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanrc= rc (sd) sdrc=rc (count) n=rc, by(ruralres rasocid_binary)
generate hirc = meanrc + invttail(n-1,0.025)*(sdrc / sqrt(n))
generate lowrc = meanrc - invttail(n-1,0.025)*(sdrc / sqrt(n))
graph bar meanrc, over(ruralres) over(rasocid_binary)
graph bar meanrc, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanrc rasocid_binary) (rcap hirc lowrc rasocid_binary, color(gray)), by(ruralres) scheme(s1mono)

/// Mean statistics in the figure note:
tabstat ftrural if ruralres==1 & rasocid_binary==1
tabstat ftrural if ruralres==1 & rasocid_binary==0
tabstat ftrural if ruralres==0 & rasocid_binary==1
tabstat ftrural if ruralres==0 & rasocid_binary==0

tabstat ftrural [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat ftrural [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat ftrural [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat ftrural [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat rc if ruralres==1 & rasocid_binary==1
tabstat rc if ruralres==1 & rasocid_binary==0
tabstat rc if ruralres==0 & rasocid_binary==1
tabstat rc if ruralres==0 & rasocid_binary==0

tabstat rc [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat rc [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat rc [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat rc [weight=weight2] if ruralres==0 & rasocid_binary==0
//////////////////////////////////////////////////////////////////////////////////////////////////////////






//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MANUSCRIPT Figure 4 //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Racial resentment ("rr") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanrr= rr (sd) sdrr=rr (count) n=rr, by(ruralres rasocid_binary)
generate hirr = meanrr + invttail(n-1,0.025)*(sdrr / sqrt(n))
generate lowrr = meanrr - invttail(n-1,0.025)*(sdrr / sqrt(n))
graph bar meanrr, over(ruralres) over(rasocid_binary)
graph bar meanrr, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanrr rasocid_binary) (rcap hirr lowrr rasocid_binary, color(gray)), by(ruralres) scheme(s1mono)

/// Moral traditionalism ("moraltrad2") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanmoraltrad2= moraltrad2 (sd) sdmoraltrad2=moraltrad2 (count) n=moraltrad2, by(ruralres rasocid_binary)
generate himoraltrad2 = meanmoraltrad2 + invttail(n-1,0.025)*(sdmoraltrad2 / sqrt(n))
generate lowmoraltrad2 = meanmoraltrad2 - invttail(n-1,0.025)*(sdmoraltrad2 / sqrt(n))
graph bar meanmoraltrad2, over(ruralres) over(rasocid_binary)
graph bar meanmoraltrad2, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanmoraltrad2 rasocid_binary) (rcap himoraltrad2 lowmoraltrad2 rasocid_binary, color(gray)), by(ruralres) scheme(s1mono)

/// Mean statistics in the figure note:
tabstat rr if ruralres==1 & rasocid_binary==1
tabstat rr if ruralres==1 & rasocid_binary==0
tabstat rr if ruralres==0 & rasocid_binary==1
tabstat rr if ruralres==0 & rasocid_binary==0

tabstat rr [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat rr [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat rr [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat rr [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat moraltrad2 if ruralres==1 & rasocid_binary==1
tabstat moraltrad2 if ruralres==1 & rasocid_binary==0
tabstat moraltrad2 if ruralres==0 & rasocid_binary==1
tabstat moraltrad2 if ruralres==0 & rasocid_binary==0

tabstat moraltrad2 [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat moraltrad2 [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat moraltrad2 [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat moraltrad2 [weight=weight2] if ruralres==0 & rasocid_binary==0

//////////////////////////////////////////////////////////////////////////////////////////////////////////









//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MANUSCRIPT TABLE 3 //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rc" = rural resentment, "moraltrad2" = moral traditionalism

logit rasocid_binary inc college black hisp female white age bornagain relig i.region [pweight=weight2] if ruralres==1, or
est store a1c
logit rasocid_binary inc college black hisp female white age bornagain relig i.region [pweight=weight2] if ruralres==0, or
est store a2c

logit rasocid_binary inc college black hisp female white age bornagain relig i.region rr moraltrad2 [pweight=weight2] if ruralres==1, or
est store a1
logit rasocid_binary inc college black hisp female white age bornagain relig i.region rr moraltrad2  [pweight=weight2] if ruralres==0, or
est store a2

logit rasocid_binary inc college black hisp female white age bornagain relig i.region ruralft2 rc [pweight=weight2] if ruralres==1, or
est store a1b
logit rasocid_binary inc college black hisp female white age bornagain relig i.region ruralft2 rc  [pweight=weight2] if ruralres==0, or
est store a2b


esttab a1c a2c a1 a2  a1b a2b using "Tableanes2020t3.rtf", eform ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////










//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MANUSCRIPT Figure 5 //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Partisanship ("pid") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanpid= pid (sd) sdpid=pid (count) n=pid, by(ruralres rasocid_binary)
generate hipid = meanpid + invttail(n-1,0.025)*(sdpid / sqrt(n))
generate lowpid = meanpid - invttail(n-1,0.025)*(sdpid / sqrt(n))
graph bar meanpid, over(ruralres) over(rasocid_binary)
graph bar meanpid, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanpid rasocid_binary) (rcap hipid lowpid rasocid_binary), by(ruralres) scheme(s1mono)

/// Symbolic ideology ("ideo") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanideo= ideo (sd) sdideo=ideo (count) n=ideo, by(ruralres rasocid_binary)
generate hiideo = meanideo + invttail(n-1,0.025)*(sdideo / sqrt(n))
generate lowideo = meanideo - invttail(n-1,0.025)*(sdideo / sqrt(n))
graph bar meanideo, over(ruralres) over(rasocid_binary)
graph bar meanideo, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanideo rasocid_binary) (rcap hiideo lowideo rasocid_binary, color(red)), by(ruralres) scheme(s1mono)

/// anti-intellectualism/anti-expertise ("anti_exp") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meananti_exp= anti_exp (sd) sdanti_exp=anti_exp (count) n=anti_exp, by(ruralres rasocid_binary)
generate hianti_exp = meananti_exp + invttail(n-1,0.025)*(sdanti_exp / sqrt(n))
generate lowanti_exp = meananti_exp - invttail(n-1,0.025)*(sdanti_exp / sqrt(n))
graph bar meananti_exp, over(ruralres) over(rasocid_binary)
graph bar meananti_exp, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meananti_exp rasocid_binary) (rcap hianti_exp lowanti_exp rasocid_binary, color(red)), by(ruralres) scheme(s1mono)

/// Anti-elitism ("anti_elite") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meananti_elite= anti_elite (sd) sdanti_elite=anti_elite (count) n=anti_elite, by(ruralres rasocid_binary)
generate hianti_elite = meananti_elite + invttail(n-1,0.025)*(sdanti_elite / sqrt(n))
generate lowanti_elite = meananti_elite - invttail(n-1,0.025)*(sdanti_elite / sqrt(n))
graph bar meananti_elite, over(ruralres) over(rasocid_binary)
graph bar meananti_elite, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meananti_elite rasocid_binary) (rcap hianti_elite lowanti_elite rasocid_binary), by(ruralres) scheme(s1mono)

/// Political interest ("interest") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meaninterest= interest (sd) sdinterest=interest (count) n=interest, by(ruralres rasocid_binary)
generate hiinterest = meaninterest + invttail(n-1,0.025)*(sdinterest / sqrt(n))
generate lowinterest = meaninterest - invttail(n-1,0.025)*(sdinterest / sqrt(n))
graph bar meaninterest, over(ruralres) over(rasocid_binary)
graph bar meaninterest, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meaninterest rasocid_binary) (rcap hiinterest lowinterest rasocid_binary), by(ruralres) scheme(s1mono)

/// Trump feeling thermometer ("trumpft") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meantrumpft= trumpft (sd) sdtrumpft=trumpft (count) n=trumpft, by(ruralres rasocid_binary)
generate hitrumpft = meantrumpft + invttail(n-1,0.025)*(sdtrumpft / sqrt(n))
generate lowtrumpft = meantrumpft - invttail(n-1,0.025)*(sdtrumpft / sqrt(n))
graph bar meantrumpft, over(ruralres) over(rasocid_binary)
graph bar meantrumpft, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meantrumpft rasocid_binary) (rcap hitrumpft lowtrumpft rasocid_binary), by(ruralres) scheme(s1mono)

/// Mean statistics for note below figure:

tabstat ideo if ruralres==1 & rasocid_binary==1
tabstat ideo if ruralres==1 & rasocid_binary==0
tabstat ideo if ruralres==0 & rasocid_binary==1
tabstat ideo if ruralres==0 & rasocid_binary==0

tabstat ideo [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat ideo [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat ideo [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat ideo [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat pid if ruralres==1 & rasocid_binary==1
tabstat pid if ruralres==1 & rasocid_binary==0
tabstat pid if ruralres==0 & rasocid_binary==1
tabstat pid if ruralres==0 & rasocid_binary==0

tabstat pid [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat pid [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat pid [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat pid [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat trumpft if ruralres==1 & rasocid_binary==1
tabstat trumpft if ruralres==1 & rasocid_binary==0
tabstat trumpft if ruralres==0 & rasocid_binary==1
tabstat trumpft if ruralres==0 & rasocid_binary==0

tabstat trumpft [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat trumpft [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat trumpft [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat trumpft [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat interest if ruralres==1 & rasocid_binary==1
tabstat interest if ruralres==1 & rasocid_binary==0
tabstat interest if ruralres==0 & rasocid_binary==1
tabstat interest if ruralres==0 & rasocid_binary==0

tabstat interest [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat interest [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat interest [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat interest [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat anti_exp if ruralres==1 & rasocid_binary==1
tabstat anti_exp if ruralres==1 & rasocid_binary==0
tabstat anti_exp if ruralres==0 & rasocid_binary==1
tabstat anti_exp if ruralres==0 & rasocid_binary==0

tabstat anti_exp [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat anti_exp [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat anti_exp [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat anti_exp [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat anti_elite if ruralres==1 & rasocid_binary==1
tabstat anti_elite if ruralres==1 & rasocid_binary==0
tabstat anti_elite if ruralres==0 & rasocid_binary==1
tabstat anti_elite if ruralres==0 & rasocid_binary==0

tabstat anti_elite [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat anti_elite [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat anti_elite [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat anti_elite [weight=weight2] if ruralres==0 & rasocid_binary==0

//////////////////////////////////////////////////////////////////////////////////////////////////////////










//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MANUSCRIPT Figure 6 and ONLINE APPENDIX Tables S10-S13 /////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Table S10
/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight, "trumpft" = Feeling termometer towards Trump

reg pid rasocid_binary ruralres inc college black hisp white female age bornagain relig ideo i.region rr [pweight=weight2]
est store m1
reg pid i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig ideo i.region rr [pweight=weight2]
est store m1a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

reg ideo rasocid_binary ruralres inc college black hisp white female age bornagain relig pid i.region rr [pweight=weight2]
est store m2
reg ideo i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid i.region rr [pweight=weight2]
est store m2a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono) saving(ideogr) title("")

reg trumpft rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m3
reg trumpft i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m3a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

esttab m1 m1a m2 m2a m3 m3a using "Tableanes2020s10.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)
		
/// Table S11
/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight, "interest" = political interest, "anti_exp" = Anti-expertise/anti-intellectualism, "anti_elite" = Anti-elitism

reg interest rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr[pweight=weight2]
est store m4
reg interest i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m4a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

reg anti_exp rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m5
reg anti_exp i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m5a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono) saving(intgr) title("")

reg anti_elite rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m6
reg anti_elite i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store  m6a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

esttab m4 m4a m5 m5a m6 m6a using "Tableanes2020s11.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)


/// Table S12
/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight, "govspend" = preference for greater government spending, "immlevel" = supports decreases in immigration level, "climateaffecting" = recognize climate change

reg govspend rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m7
reg govspend i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m7a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono) saving(spendgr) title("")

reg immlevel rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m8
reg immlevel i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m8a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono) saving(immgr) title("")

reg climateaffecting rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m9
reg climateaffecting i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m9a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

esttab m7 m7a m8 m8a m9 m9a using "Tableanes2020s12.rtf",  ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)

/// Table S13
/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight, "covidlimst" = support policies that limit the spread of COVID-19, "blmft" = feeling thermometer towards Black Lives Matter, "abortion" = more supportive of women's ability to get abortions

reg covidlimst rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m10
reg covidlimst i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m10a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

reg blmft rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m11
reg blmft i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m11a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono)

ologit abortion rasocid_binary ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m12
ologit abortion i.rasocid_binary##i.ruralres inc college black hisp white female age bornagain relig pid ideo i.region rr [pweight=weight2]
est store m12a
margins, at(rasocid_binary=(0 1) ruralres=(0 1))
marginsplot, scheme(s1mono) 
		
esttab m10 m10a m11 m11a m12 m12a using "Tableanes2020s13.rtf",  ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)

		
/// Figure 6 - run the code above for tables S10-S13 and then run the code below:	
graph combine ideogr.gph intgr.gph spendgr.gph immgr.gph, scheme(s1mono) title("")
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////







//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S4 ///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight
logit rasocid_binary i.ruralres [pweight=weight2], or
est store r1
logit rasocid_binary ruralres inc college black hisp female white age bornagain relig i.region [pweight=weight2], or
est store r2

esttab r1 r2 using "Tableanes2020ruralbyrurals4.rtf", eform ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////


		
		
		
		
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Figure S3 //////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "rasocid_binary" = rural identity (binary), "region" = Census region, "ruralres" = rural resident
logit rasocid_binary i.region##i.ruralres [pweight=weight2]
margins, at(region=(1 2 3 4) ruralres=(0 1))
marginsplot, scheme(s1mono)

//////////////////////////////////////////////////////////////////////////////////////////////////////////







//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Figure S5 ///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Support for lower levels of immigration ("immlevel") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanimmlevel= immlevel (sd) sdimmlevel=immlevel (count) n=immlevel, by(ruralres rasocid_binary)
generate hiimmlevel = meanimmlevel + invttail(n-1,0.025)*(sdimmlevel / sqrt(n))
generate lowimmlevel = meanimmlevel - invttail(n-1,0.025)*(sdimmlevel / sqrt(n))
graph bar meanimmlevel, over(ruralres) over(rasocid_binary)
graph bar meanimmlevel, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanimmlevel rasocid_binary) (rcap hiimmlevel lowimmlevel rasocid_binary), by(ruralres) scheme(s1mono)

/// Belief in climate change ("climateaffecting") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanclimateaffecting= climateaffecting (sd) sdclimateaffecting=climateaffecting (count) n=climateaffecting, by(ruralres rasocid_binary)
generate hiclimateaffecting = meanclimateaffecting + invttail(n-1,0.025)*(sdclimateaffecting / sqrt(n))
generate lowclimateaffecting = meanclimateaffecting - invttail(n-1,0.025)*(sdclimateaffecting / sqrt(n))
graph bar meanclimateaffecting, over(ruralres) over(rasocid_binary)
graph bar meanclimateaffecting, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanclimateaffecting rasocid_binary) (rcap hiclimateaffecting lowclimateaffecting rasocid_binary), by(ruralres) scheme(s1mono)

/// Support for increased government spending ("govspend") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meangovspend= govspend (sd) sdgovspend=govspend (count) n=govspend, by(ruralres rasocid_binary)
generate higovspend = meangovspend + invttail(n-1,0.025)*(sdgovspend / sqrt(n))
generate lowgovspend = meangovspend - invttail(n-1,0.025)*(sdgovspend / sqrt(n))
graph bar meangovspend, over(ruralres) over(rasocid_binary)
graph bar meangovspend, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meangovspend rasocid_binary) (rcap higovspend lowgovspend rasocid_binary), by(ruralres) scheme(s1mono)

/// Support for policies limiting the spread of COVID-19 ("covidlimst") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meancovidlimst= covidlimst (sd) sdcovidlimst=covidlimst (count) n=covidlimst, by(ruralres rasocid_binary)
generate hicovidlimst = meancovidlimst + invttail(n-1,0.025)*(sdcovidlimst / sqrt(n))
generate lowcovidlimst = meancovidlimst - invttail(n-1,0.025)*(sdcovidlimst / sqrt(n))
graph bar meancovidlimst, over(ruralres) over(rasocid_binary)
graph bar meancovidlimst, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meancovidlimst rasocid_binary) (rcap hicovidlimst lowcovidlimst rasocid_binary), by(ruralres) scheme(s1mono)

/// Black Lives Matter feeling thermometer ("blmft") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanblmft= blmft (sd) sdblmft=blmft (count) n=blmft, by(ruralres rasocid_binary)
generate hiblmft = meanblmft + invttail(n-1,0.025)*(sdblmft / sqrt(n))
generate lowblmft = meanblmft - invttail(n-1,0.025)*(sdblmft / sqrt(n))
graph bar meanblmft, over(ruralres) over(rasocid_binary)
graph bar meanblmft, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanblmft rasocid_binary) (rcap hiblmft lowblmft rasocid_binary), by(ruralres) scheme(s1mono)

/// Support for greater abortion access ("abortion") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
collapse (mean) meanabortion= abortion (sd) sdabortion=abortion (count) n=abortion, by(ruralres rasocid_binary)
generate hiabortion = meanabortion + invttail(n-1,0.025)*(sdabortion / sqrt(n))
generate lowabortion = meanabortion - invttail(n-1,0.025)*(sdabortion / sqrt(n))
graph bar meanabortion, over(ruralres) over(rasocid_binary)
graph bar meanabortion, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanabortion rasocid_binary) (rcap hiabortion lowabortion rasocid_binary), by(ruralres) scheme(s1mono)

/// Mean statistics for note below figure:

tabstat govspend if ruralres==1 & rasocid_binary==1
tabstat govspend if ruralres==1 & rasocid_binary==0
tabstat govspend if ruralres==0 & rasocid_binary==1
tabstat govspend if ruralres==0 & rasocid_binary==0

tabstat govspend [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat govspend [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat govspend [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat govspend [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat immlevel if ruralres==1 & rasocid_binary==1
tabstat immlevel if ruralres==1 & rasocid_binary==0
tabstat immlevel if ruralres==0 & rasocid_binary==1
tabstat immlevel if ruralres==0 & rasocid_binary==0

tabstat immlevel [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat immlevel [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat immlevel [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat immlevel [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat climateaffecting if ruralres==1 & rasocid_binary==1
tabstat climateaffecting if ruralres==1 & rasocid_binary==0
tabstat climateaffecting if ruralres==0 & rasocid_binary==1
tabstat climateaffecting if ruralres==0 & rasocid_binary==0

tabstat climateaffecting [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat climateaffecting [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat climateaffecting [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat climateaffecting [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat covidlimst if ruralres==1 & rasocid_binary==1
tabstat covidlimst if ruralres==1 & rasocid_binary==0
tabstat covidlimst if ruralres==0 & rasocid_binary==1
tabstat covidlimst if ruralres==0 & rasocid_binary==0

tabstat covidlimst [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat covidlimst [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat covidlimst [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat covidlimst [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat blmft if ruralres==1 & rasocid_binary==1
tabstat blmft if ruralres==1 & rasocid_binary==0
tabstat blmft if ruralres==0 & rasocid_binary==1
tabstat blmft if ruralres==0 & rasocid_binary==0

tabstat blmft [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat blmft [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat blmft [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat blmft [weight=weight2] if ruralres==0 & rasocid_binary==0

tabstat abortion if ruralres==1 & rasocid_binary==1
tabstat abortion if ruralres==1 & rasocid_binary==0
tabstat abortion if ruralres==0 & rasocid_binary==1
tabstat abortion if ruralres==0 & rasocid_binary==0

tabstat abortion [aweight=weight2] if ruralres==1 & rasocid_binary==1
tabstat abortion [weight=weight2] if ruralres==1 & rasocid_binary==0
tabstat abortion [weight=weight2] if ruralres==0 & rasocid_binary==1
tabstat abortion [weight=weight2] if ruralres==0 & rasocid_binary==0

//////////////////////////////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S17 ///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, region" = Census region, "rr" = racial resentment, "weight2" = survey weight2, "bornagain" = Born Again Christian, "moraltrad2" = Moral traditionalism

logit rasocid_binary inc college hisp female age bornagain relig i.region [pweight=weight2] if ruralres==1 & white==1, or
est store w1c
logit rasocid_binary inc college hisp female age bornagain relig i.region [pweight=weight2] if ruralres==0 & white==1, or
est store w2c

logit rasocid_binary inc college hisp female age bornagain relig i.region rr moraltrad2 [pweight=weight2] if ruralres==1 & white==1, or
est store w1
logit rasocid_binary inc college hisp female age bornagain relig i.region rr moraltrad2  [pweight=weight2] if ruralres==0 & white==1, or
est store w2

esttab w1c w2c w1 w2 using "Tableanes2020t-white2.rtf", eform ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)

//////////////////////////////////////////////////////////////////////////////////////////////////////////







//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Figure S9 ///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// among whites ("white"), moral traditionalism ("moraltrad2") by rural identity ("rasocid_binary") and rural residency ("ruralres")
/// Note that if you run this, you will have to reopen the data file to run other analyses
drop if white != 1
collapse (mean) meanmoraltrad2= moraltrad2 (sd) sdmoraltrad2=moraltrad2 (count) n=moraltrad2, by(ruralres rasocid_binary)
generate himoraltrad2 = meanmoraltrad2 + invttail(n-1,0.025)*(sdmoraltrad2 / sqrt(n))
generate lowmoraltrad2 = meanmoraltrad2 - invttail(n-1,0.025)*(sdmoraltrad2 / sqrt(n))
graph bar meanmoraltrad2, over(ruralres) over(rasocid_binary)
graph bar meanmoraltrad2, over(ruralres) over(rasocid_binary) asyvars
graph twoway (bar meanmoraltrad2 rasocid_binary) (rcap himoraltrad2 lowmoraltrad2 rasocid_binary, color(red)), by(ruralres) scheme(s1mono)

/// Mean statistics in the note:

tabstat moraltrad2 if ruralres==1 & rasocid_binary==1 & white==1
tabstat moraltrad2 if ruralres==1 & rasocid_binary==0 & white==1
tabstat moraltrad2 if ruralres==0 & rasocid_binary==1 & white==1
tabstat moraltrad2 if ruralres==0 & rasocid_binary==0 & white==1

tabstat moraltrad2 [aweight=weight2] if ruralres==1 & rasocid_binary==1 & white==1
tabstat moraltrad2 [weight=weight2] if ruralres==1 & rasocid_binary==0 & white==1
tabstat moraltrad2 [weight=weight2] if ruralres==0 & rasocid_binary==1 & white==1
tabstat moraltrad2 [weight=weight2] if ruralres==0 & rasocid_binary==0 & white==1

//////////////////////////////////////////////////////////////////////////////////////////////////////////






//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Tables S18-19 ///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Table S18
tab rasocid_binary ruralres if region==1, cell nofreq
tab rasocid_binary ruralres if region==2, cell nofreq
tab rasocid_binary ruralres if region==3, cell nofreq
tab rasocid_binary ruralres if region==4, cell nofreq
/// Table S19
tabstat rc if region==1
tabstat rc if region==2
tabstat rc if region==3
tabstat rc if region==4

//////////////////////////////////////////////////////////////////////////////////////////////////////////







//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Tables S20 and Figure S10 ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight, "rr" = racial resentment, "moraltrad2" = moral traditionalism

/// Table S20
logit rasocid_binary ruralres i.region [pweight=weight], or
est store region1
logit rasocid_binary ruralres i.region inc college black hisp female white age bornagain relig i.region pid ideo rr moraltrad2 [pweight=weight], or
est store region2
logit rasocid_binary i.ruralres##i.region inc college black hisp female white age bornagain relig i.region pid ideo rr moraltrad2 [pweight=weight], or
est store regionint

esttab region1 region2 regionint using "Tableanes2020regions.rtf", eform ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)

/// Figure S10
margins, at(ruralres=(0 1) region=(1 2 3 4))
marginsplot, scheme(s1mono)
//////////////////////////////////////////////////////////////////////////////////////////////////////////






//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S21 ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "pid" = partisanship, "rasocid_binary" = rural identity (binary), "ruralres" = rural resident, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "ideo" = ideology, "region" = Census region, "rr" = racial resentment, "weight2" = survey weight, "rr" = racial resentment, "moraltrad2" = moral traditionalism, "rc" = rural resentment, "bornagain" = Born Again Christian

reg rc i.region [pweight=weight] if rasocid_binary==1 & ruralres==0
est store region4a
reg rc i.region inc college black hisp female white age bornagain relig i.region pid ideo rr moraltrad2 [pweight=weight] if rasocid_binary==1 & ruralres==0
est store region4

esttab region4a region4 using "Tableanes2020regionxrca.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)	
//////////////////////////////////////////////////////////////////////////////////////////////////////////



